using System;
using System.Collections.Generic;
using MediatR;
using RBAC.ErrorCode;

namespace RBAC.Write.Api.Application.Command.ERP.PurchasingManagement.PurchaseArrivalNotes
{
    /// <summary>
    /// 编辑采购到货单（主表 + 可选重置明细）命令
    /// </summary>
    public class UpdatePurchaseArrivalNoteCommand : IRequest<APIResult<int>>
    {
        /// <summary>
        /// 到货单主键ID
        /// </summary>
        public long Id { get; set; }

        // 主表字段（与 ArrivalOrderInfo 对齐，可选更新）
        public string DocCode { get; set; }
        public string BizType { get; set; }
        public string PurchaseOrderNo { get; set; }
        public string DeliveryNote { get; set; }
        public DateTime DocDate { get; set; }
        public string Operator { get; set; }
        public string SupplierId { get; set; }
        public string DocStatus { get; set; }
        public string Auditor { get; set; }
        public string Warehouse { get; set; }
        public int BizStatus { get; set; }
        public DateTime? AuditDate { get; set; }
        public string Progress { get; set; }
        public string Remark { get; set; }

        /// <summary>
        /// 若提供则重置明细（先删后插）。不提供则仅改主表。
        /// </summary>
        public List<PurchaseArrivalMaterialDetailUpdateDto>? Details { get; set; }
    }

    /// <summary>
    /// 采购到货单明细 DTO（与 ArrivalOrderMaterialInfo 对齐；更新时仅用于重置写入）
    /// </summary>
    public class PurchaseArrivalMaterialDetailUpdateDto
    {
        public string DocumentaryNumber { get; set; }
        public string SupplierContractNo { get; set; }
        public string MaterialCode { get; set; }
        public string MaterialName { get; set; }
        public string MainUnit { get; set; }
        public decimal Quantity { get; set; }
        public string BatchNo { get; set; }
        public decimal InboundQuantity { get; set; }
        public string ArrivalDescription { get; set; }
    }
}
